home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagd_f.zip / EGAVGA.SWG / 0079_EGA-VGA Bitplanes.pas < prev    next >
Pascal/Delphi Source File  |  1994-01-27  |  5KB  |  113 lines

  1. {
  2. > Attention: All those who are familiar with graphics ports
  3. > (ie. Sean Palmer, Jan Doggen, and others I don't yet know).
  4.  
  5. Don't consider myself that familiar with 'em, but here are some
  6. snippets and remarks. BTW I consider phasing out all BGI stuff in my
  7. code in the first half of '93 or so, which will be a major effort.
  8. After that, I'll rank myself among the register-twiddlers. Maybe we
  9. should team up on this project if you plan on going in that direction
  10. too.
  11.  
  12. > Would you mind explaining the EGA map mask (?) and
  13. > sequencer (?) register ports (I don't know what they are
  14. > *really* called, but they are the ones that control which
  15. > bitplane gets written to in EGA mode
  16. > 640x350x16, 4 bitplanes) to me (please)?
  17.  
  18. There are several write modes and read modes for EGA/VGA, and the
  19. exact workings of the registers depend on the mode. What you are
  20. talking about (I assume) is read/write mode 0 which you would use
  21. to pump bytes directly into a bit plane. I use the following
  22. procedure for this:
  23.  
  24.  
  25. (*************************** EGA/VGA bit planes ****************************)
  26. }
  27.  
  28. CONST
  29.   GDCIndexReg = $3CE;  { Index register of EGA/VGA Graphics Device Controller }
  30.   GDCDataReg  = $3CF;  { Data  register of EGA/VGA Graphics Device Controller }
  31.   SeqIndexReg = $3C4;  { Index register of EGA/VGA Sequencer }
  32.   SeqDataReg  = $3C5;  { Data  register of EGA/VGA Sequencer }
  33.  
  34. PROCEDURE PrepareBitPlaneRead(Plane: Byte);
  35.   BEGIN
  36.     Port[GDCIndexReg] := 5;           { Number of Mode register }
  37.     Port[GDCDataReg ] := 0;           { Value of register: 0: read mode 0 }
  38.     Port[GDCIndexReg] := 4;           { Number of Read Map Select register }
  39.     Port[GDCDataReg ] := Plane;       { Value of register: bit for plane to
  40. read }
  41.   END; { PrepareBitPlaneRead }
  42.  
  43.  
  44. PROCEDURE ConcludeBitPlaneRead(Plane: Byte);
  45.   BEGIN
  46.     Port[GDCIndexReg] := 5;           { Number of Mode register }
  47.     Port[GDCDataReg ] := $10;         { Value of register: 10: default for
  48. modes 10h and 12h }
  49.     Port[GDCIndexReg] := 4;           { Number of Read Map Select register }
  50.     Port[GDCDataReg ] := 0;           { Value of register: plane to read }
  51.   END; { ConcludeBitPlaneRead }
  52.  
  53.  
  54. PROCEDURE PrepareBitPlaneWrite(Plane,PutMode: Byte);
  55.   BEGIN
  56.     Port[GDCIndexReg] := 5;           { Number of Mode register }
  57.     Port[GDCDataReg ] := 0;           { Value of register: 0: write mode 0 }
  58.     Port[GDCIndexReg] := 1;           { Number of Enable Set/Reset register }
  59.     Port[GDCDataReg ] := 0;           { Value of register: 0 }
  60.     Port[GDCIndexReg] := 3;           { Number of Data Rotate/Function Select
  61. register }
  62.    (* Bits 3 and 4 from the Rotate/Function Select register mean:
  63.     *          Bit 4  Bit 3   Replacement function:
  64.     *            0      0           Replace
  65.     *            0      1           AND
  66.     *            1      0           OR
  67.     *            1      1           XOR    *)
  68.     CASE PutMode OF
  69.       AndPut : Port[GDCDataReg] :=  8;   { No rotation; AND with buffer }
  70.       OrPut  : Port[GDCDataReg] := 16;   { No rotation; OR  with buffer }
  71.       XORPut : Port[GDCDataReg] := 24    { No rotation; XOR with buffer }
  72.     ELSE
  73.       Port[GDCDataReg] :=  0;    { No rotation; replace; use this as default }
  74.     END; { CASE }
  75.     Port[GDCIndexReg] := 8;           { Number of BitMask register }
  76.     Port[GDCDataReg ] := $FF;         { Value of register: $FF: use all bits }
  77.     Port[SeqIndexReg] := 2;           { Number of Map Mask register }
  78.     Port[SeqDataReg ] := 1 SHL Plane; { Value of register: plane number }
  79.   END; { PrepareBitPlaneWrite }
  80.  
  81.  
  82. PROCEDURE ConcludeBitPlaneWrite(Plane: Byte);
  83.   BEGIN
  84.     Port[GDCIndexReg] := 1;           { Number of Enable Set/Reset register }
  85.     Port[GDCDataReg ] := 0;           { Value of register: 0 }
  86.     Port[SeqIndexReg] := 2;           { Number of Map Mask register }
  87.     Port[SeqDataReg ] := $0F;         { Value of register: Enable all planes }
  88.     Port[GDCIndexReg] := 3;           { Number of Data Rotate/Function Select
  89. register }
  90.     Port[GDCDataReg ] := 0;           { Value of register: No rotation; replace
  91. }
  92.   END; { ConcludeBitPlaneWrite }
  93.  
  94. {
  95. A good explanation can be found in:
  96.   Wilton,R - Programmers' guide to PC and PS/2 video systems
  97.   Microsoft Press
  98.  
  99. You should invest in some books on EGA/VGA programming if you have
  100. more of these questions, otherwise you're being 'penny wise, pound
  101. foolish'.
  102.  
  103. The book by Wilton is considered more or less a 'must have' together
  104. with
  105.   Ferraro, R.F. - Programmer's guide to the EGA and VGA cards
  106.   Addison-Wesley
  107.  
  108. Ferraro gives you detailed register info. It also deals with Super
  109. VGAs. Because I'll have to expand a program to use VESA super VGA
  110. modes, I bought this together with:
  111.   Rimmer, S - Super VGA graphics programming secrets
  112.   WindCrest/McGraw Hill
  113. }